package com.rytx.web.controller.ysp;

import com.rytx.common.core.controller.BaseController;
import com.rytx.common.core.domain.AjaxResult;
import com.rytx.common.core.page.TableDataInfo;
import com.rytx.system.domain.ysp.ArtFundingDetails;
import com.rytx.system.service.IArtFundingDetailsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/system/fundingDetails")
@Api(value = "ArtFundingDetailsController", tags = "收支统计接口")
public class ArtFundingDetailsController extends BaseController {
    @Autowired
    private IArtFundingDetailsService artFundingDetailsService;


    @GetMapping("/artFundingDetails")
    @ApiOperation(
            value = "查询艺术收支统计列表",
            notes = "查询艺术收支统计列表",
            response = TableDataInfo.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name="fundingType",value="资金类型，1-收入（扣款），2-支出（退款）"),
            @ApiImplicitParam(name="groupBy",value="分组类型 year-按年，month-按月，day-按日，默认按当月"),
            @ApiImplicitParam(name="statisticsYear",value="统计年份"),
            @ApiImplicitParam(name="statisticsMonth",value="统计月份"),
            @ApiImplicitParam(name="statisticsDay",value="统计日"),
    })
    public TableDataInfo artFundingDetails(ArtFundingDetails artFundingDetails) {
        if(artFundingDetails.getGroupBy() == null){
            artFundingDetails.setGroupBy("day");
            artFundingDetails.setStatisticsDay(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
        }
        startPage();
        List<ArtFundingDetails> list = artFundingDetailsService.selectArtFundingDetailsStatisticsByParam(artFundingDetails);
        return getDataTable(list);
    }

    @GetMapping("/detailList")
    @ApiOperation(
            value = "查询艺术收支明细列表",
            notes = "查询艺术收支明细列表",
            response = TableDataInfo.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name="fundingType",value="资金类型，1-收入（扣款），2-支出（退款）"),
            @ApiImplicitParam(name="statisticsYear",value="统计年份"),
            @ApiImplicitParam(name="statisticsMonth",value="统计月份"),
            @ApiImplicitParam(name="statisticsDay",value="统计日"),
    })
    public TableDataInfo detailList(ArtFundingDetails artFundingDetails) {
//        if(artFundingDetails.getGroupBy() == null){
//            artFundingDetails.setGroupBy("day");
//            artFundingDetails.setStatisticsDay(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
//        }
        startPage();
        List<ArtFundingDetails> list = artFundingDetailsService.detailList(artFundingDetails);
        return getDataTable(list);
    }
}
